﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using CSA.Lib;

namespace CSA.OptimalMonitoringNetwork
{
    public partial class OMNCustomEncodeUI : CSCustomUI
    {
        CSOMNProblem m_Problem;

        public override CSAlgorithmSettings AlgorithmSettings
        {
            get
            {
                return base.AlgorithmSettings;
            }
            set
            {
                base.AlgorithmSettings = value;
                txtCandidateStations.DataBindings.Clear();
                txtExistingStations.DataBindings.Clear();
                updNewStations.DataBindings.Clear();
                if (AlgorithmSettings == null)
                {
                    m_Problem = null;
                    txtCandidateStations.Text = "";
                    return;
                }
                m_Problem =(CSOMNProblem) AlgorithmSettings.SpatialOptimizationProblem;
                if (m_Problem != null)
                {
                    txtCandidateStations.DataBindings.Add("Text", m_Problem, "CandidateStationFile");
                    txtExistingStations.DataBindings.Add("Text", m_Problem, "ExistingStationFile");
                    updNewStations.DataBindings.Add("Value", m_Problem, "NewStationCount");
                }                
            }
        }

        public CSOMNProblem ProblemInfo
        {
            get { return m_Problem; }          
        }
        public OMNCustomEncodeUI()
        {
            InitializeComponent();
        }
     

        private void txtPath_TextChanged(object sender, EventArgs e)
        {
            try
            {
       
            }
            catch
            { }
        }

        private void btnSelectCandidateStations_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "ESRI Shape file|*.shp";
            dlg.Title = "Please select a point shp file saving the candidate stations.";
            dlg.Multiselect = false;
            DialogResult re = dlg.ShowDialog();
            if (re == System.Windows.Forms.DialogResult.OK)
            {
                txtCandidateStations.Text = dlg.FileName;
                txtCandidateStations.Focus();
            }
        }
  
        private void CustomEncodeUI_Load(object sender, EventArgs e)
        {
            txtMemo.Text = global::CSA.OptimalMonitoringNetwork.TextString.EncodeDes;
        }

        private void btnSelectExistingStations_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "ESRI Shape file|*.shp";
            dlg.Title = "Please select a point shp file saving the existing stations.";
            dlg.Multiselect = false;
            DialogResult re = dlg.ShowDialog();
            if (re == System.Windows.Forms.DialogResult.OK)
            {
                txtExistingStations.Text = dlg.FileName;
                txtExistingStations.Focus();
            }
        }



    }
}
